//
//  HomeTableHeaderCell.m
//  ZZmetro
//
//  Created by 一介布衣 on 2020/6/15.
//  Copyright © 2020 一介布衣. All rights reserved.
//

#import "HomeTableHeaderCell.h"
#import "SDCycleScrollView.h"

@interface HomeTableHeaderCell() <SDCycleScrollViewDelegate>
//Banner广告
@property(nonatomic,strong) SDCycleScrollView *bannerAd;
//滚动文字广告
@property(nonatomic,strong) SDCycleScrollView *textAd;
@end


@implementation HomeTableHeaderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        //UILabel *label = [UILabel new];
        //label.frame = CGRectMake(0, 0, 200, 60);
        //label.text = @"我是Header TableViewCell";
        //label.textAlignment = NSTextAlignmentCenter;
        //[self.contentView addSubview:label];
        
        [self.contentView addSubview:self.bannerAd];
        [self.contentView addSubview:self.textAd];
    }
    return self;
}



-(SDCycleScrollView *)bannerAd {
    
    NSArray *imagesURLStrings = @[@"http://eimg.smzdm.com/201706/21/5949c794a058193.png",
                                  @"http://eimg.smzdm.com/201706/20/594872b3ce4897616.png",
                                  @"http://eimg.smzdm.com/201706/21/5949c759c9ec75211.png",
                                  @"http://eimg.smzdm.com/201706/20/59490304c13471312.jpg",
                                  @"http://eimg.smzdm.com/201706/20/5948c8333d5242625.png"];
    
    _bannerAd = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0,SCREEN_WIDTH, 200)
            delegate:self
    placeholderImage:[UIImage imageNamed:@"bg_welcome.jpeg"]];
    
    _bannerAd.currentPageDotColor = [UIColor whiteColor];
    _bannerAd.imageURLStringsGroup = imagesURLStrings;
    _bannerAd.autoScrollTimeInterval = 5;
    //_bannerAd.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
    _bannerAd.currentPageDotColor = [UIColor redColor];
    _bannerAd.pageDotColor = [UIColor whiteColor];
    _bannerAd.layer.masksToBounds = YES;
    
    return _bannerAd;
}

-(SDCycleScrollView *)textAd {
    if (!_textAd) {
        NSArray *textStrings = @[@"纯文字上下滚动轮播，纯文字上下滚动轮播1",
                                 @"纯文字上下滚动轮播，纯文字上下滚动轮播2",
                                 @"纯文字上下滚动轮播，纯文字上下滚动轮播3",
                                 @"纯文字上下滚动轮播，纯文字上下滚动轮播4"];
        _textAd = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(10, 200, SCREEN_WIDTH-10, 36) delegate:self placeholderImage:nil];
        _textAd.scrollDirection = UICollectionViewScrollDirectionVertical;
        _textAd.onlyDisplayText = YES;
        _textAd.titlesGroup = textStrings;
        _textAd.titleLabelTextColor = [UIColor darkTextColor];
        _textAd.titleLabelBackgroundColor = [UIColor whiteColor];
        _textAd.titleLabelTextFont = [UIFont systemFontOfSize:16]; //字体大小
    }
    
    return _textAd;
}

/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
    
}

/** 图片滚动回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didScrollToIndex:(NSInteger)index {
    
}

@end
